package com.hotelManagerSystem.controller;


import com.hotelManagerSystem.model.Dish;
import com.hotelManagerSystem.service.IDishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author treasy
 * @since 2021-12-22
 */
@Controller
@RequestMapping("/dish")
class DishController {
    @Autowired
    IDishService iDishService;

    @RequestMapping("/dishUI")
    public String distUI() {
        return "dish/dish-list";
    }

    @RequestMapping("/submitOrderUI")
    public String submitOrderUI() {
        return "dish/submit-order";
    }

    @RequestMapping("/dishAddUI")
    public String dishAddUI() {
        return "dish/dish-add";
    }

    @RequestMapping("/add")
    public Map<String, Object> add(@RequestParam("imageFile")MultipartFile imageFile, Dish dish) {
        return iDishService.addOne(dish, imageFile);
    }

    @ResponseBody
    @RequestMapping("/list")
    public Map<String, Object> queryAll() {
        return iDishService.queryAll();
    }

    @ResponseBody
    @RequestMapping("/queryByName")
    public Map<String, Object> queryByName(String name) {
        return iDishService.queryByName(name);
    }
}

